﻿using Microsoft.Xna.Framework;


namespace LoD.WPClientLibrary.Animations {
    public class WrapBoundary : Animation {
        private Rectangle _boundary;

        public WrapBoundary(Rectangle boundary) {
            Animating = true;
            this._boundary = boundary;
        }

        public override Vector2 ModifyPosition(Vector2 original) {
            Vector2 pos = original;

            if (pos.X < this._boundary.Left) pos.X = this._boundary.Right;
            else if (pos.X > this._boundary.Right) pos.X = this._boundary.Left;

            if (pos.Y < this._boundary.Top) pos.Y = this._boundary.Bottom;
            else if (pos.Y > this._boundary.Bottom) pos.Y = this._boundary.Top;

            return pos;
        }
    }
}